CallStyle

Helper class for generating large-format notifications that include a caller and required actions, and indicate an incoming call. If the platform does not provide large-format notifications, this method has no effect. The user will always see the normal notification view. This class is a "rebuilder": It attaches to a Builder object and modifies its behavior, like so:

Notification notification = new NotificationCompat.Builder(mContext)
    .setSmallIcon(R.drawable.new_post)
    .setStyle(
            new Notification.CallStyle.forIncomingCall(caller, declineIntent, answerIntent))
    .build();
Note that for CallStyle Notifications on API versions before 31 to be ranked as they are in API versions 31+, they must be associated with a foreground service. Additionally, CallStyle Notifications on API versions before 31 can achieve the similar ranking by marking the Notification as colorized, using setColorized.

Constructors

Link copied to clipboard
constructor()
constructor(@Nullable builder: @Nullable NotificationCompat.Builder)
Creates a CallStyle linked to a notification builder.

Types

Link copied to clipboard

Properties

Link copied to clipboard
Call type for incoming calls.
Link copied to clipboard
Call type for ongoing calls.
Link copied to clipboard
Call type for calls that are being screened.
Link copied to clipboard
Unknown call type.

Functions

Link copied to clipboard
open fun addCompatExtras(@NonNull extras: @NonNull Bundle)
Link copied to clipboard
Link copied to clipboard
@NonNull
open fun forIncomingCall(@NonNull person: @NonNull Person, @NonNull declineIntent: @NonNull PendingIntent, @NonNull answerIntent: @NonNull PendingIntent): @NonNull NotificationCompat.CallStyle
Creates a CallStyle for an incoming call.
Link copied to clipboard
@NonNull
open fun forOngoingCall(@NonNull person: @NonNull Person, @NonNull hangUpIntent: @NonNull PendingIntent): @NonNull NotificationCompat.CallStyle
Creates a CallStyle for an ongoing call.
Link copied to clipboard
@NonNull
open fun forScreeningCall(@NonNull person: @NonNull Person, @NonNull hangUpIntent: @NonNull PendingIntent, @NonNull answerIntent: @NonNull PendingIntent): @NonNull NotificationCompat.CallStyle
Creates a CallStyle for a call that is being screened.
Link copied to clipboard
Gets the actions list for the call with the answer/decline/hangUp actions inserted in the correct place.
Link copied to clipboard
Sets an optional color to be used as a hint for the Answer action button's color.
Link copied to clipboard
Sets an optional color to be used as a hint for the Decline or Hang Up action button's color.
Link copied to clipboard
@NonNull
open fun setIsVideo(isVideo: Boolean): @NonNull NotificationCompat.CallStyle
Sets whether the call is a video call, which may affect the icons or text used on the required action buttons.
Link copied to clipboard
@NonNull
open fun setVerificationIcon(@Nullable verificationIcon: @Nullable Bitmap): @NonNull NotificationCompat.CallStyle
@RequiresApi(value = 23)
@NonNull
open fun setVerificationIcon(@Nullable verificationIcon: @Nullable Icon): @NonNull NotificationCompat.CallStyle
Sets an optional icon to be displayed with text as a verification status of the caller.
Link copied to clipboard
@NonNull
open fun setVerificationText(@Nullable verificationText: @Nullable CharSequence): @NonNull NotificationCompat.CallStyle
Sets optional text to be displayed with an icon as a verification status of the caller.